#ifndef SINK_SETTING_H_INCLUDED
#define SINK_SETTING_H_INCLUDED

#include <pthread.h>
#include "timer.h"
#include "udp.h"

enum _SinkType { FSINK1 = 0, BSINK1, FSINK2, BSINK2, INVALID_SINK };
typedef enum _SinkType SinkType;

enum _ResetState { SINK_RESET_COMPLETE = 0, SINK_RESET, SINK_DELTA };
typedef enum _ResetState ResetState;

typedef struct _SINK_SETTING SINK_SETTING;

struct _SINK_SETTING
{
    short pos[4];
    short des_pos[4];

    short zero[4];

    pthread_t th_work;
    BOOL exit;
    ResetState reset_state;
    CHECK_TIMER timer;
    SinkType sink_type;         /* 要执行的辛克 */
    int ctype;                  /* 机头类型 */
    int warn;                   /* 报警 */
    MH_UDP *pudp;

    int (*reset)(MH_UDP *pudp, int ctype, short *find_zero, int num);
    int (*exec)(MH_UDP *pudp, int ctype, short *delta, short *find_zero, int num);
};

SINK_SETTING* sink_setting_new();
int sink_setting_reset(SINK_SETTING *sink_setting, int ctype);
int sink_setting_exec(SINK_SETTING *sink_setting, int ctype, SinkType sink_type, short des_pos);
void sink_setting_close(SINK_SETTING *sink_setting);
void sink_setting_set_zero(SINK_SETTING *sink_setting, short fzero, short bzero);
void sink_setting_set_zero2(SINK_SETTING *sink_setting, short fzero, short bzero);

#endif // SINK_SETTING_H_INCLUDED
